package dreamCookGame;

import java.awt.Point;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.image.BufferedImage;

import javax.swing.JComponent;
import javax.swing.JPanel;

public class EventHandler extends JComponent implements MouseListener, MouseMotionListener, KeyListener{
	Controller _controller;

	
	public EventHandler(Controller controller){
	//	super.paintComponent(this.getGraphics());
		addMouseListener(this);
		addMouseMotionListener(this);
		addKeyListener(this);
		setFocusable(true);
		_controller = controller;	
	}

	public void mouseClicked(MouseEvent e) {
		_controller.processMouseEvent("mouseClicked", e.getX(), e.getY());
	}

	public void mouseEntered(MouseEvent arg0) {
		
	}

	public void mouseExited(MouseEvent arg0) {
		
	}

	public void mousePressed(MouseEvent event) {		
	}

	public void mouseReleased(MouseEvent event) {
		
	}

	public void mouseDragged(MouseEvent event) {
		
	}

	public void mouseMoved(MouseEvent e) {
		_controller.processMouseEvent("mouseMoved", e.getX(), e.getY());
	}

	public void keyPressed(KeyEvent event) {	
		//TODO: Add flag for when character should be walking to make smooth (Brittany)
		_controller.processKeyEvent(event.getKeyChar());		
	}

	public void keyReleased(KeyEvent event) {
		//TODO: Add flag for when character should be walking to make smooth (Brittany)
		_controller.processReleasedKeyEvent(event.getKeyChar());
	}

	public void keyTyped(KeyEvent event) {
		
	}

}
